#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
检查Bot信息脚本
"""

import asyncio
from telethon import TelegramClient

# API配置
api_id = 29668108
api_hash = "578251ccac8cb1c47b91721c4bad11a2"

async def check_bot_info(bot_token):
    """检查Bot信息"""
    print("正在检查Bot信息...")
    
    try:
        # 创建客户端
        client = TelegramClient('bot_check_session', api_id, api_hash)
        
        # 启动Bot客户端
        await client.start(bot_token=bot_token)
        
        if client.is_connected():
            print("✓ Bot连接成功！")
            
            # 获取Bot信息
            me = await client.get_me()
            print(f"Bot名称: {me.first_name}")
            print(f"Bot用户名: @{me.username}")
            print(f"Bot ID: {me.id}")
            print(f"Bot类型: {'Bot' if me.bot else 'User'}")
            
            # 检查Bot是否可用
            if me.username:
                print(f"\n✅ 您的Bot用户名是: @{me.username}")
                print(f"在群组中搜索时，请使用: {me.username}")
            else:
                print("\n❌ Bot没有用户名，需要设置用户名")
                
        else:
            print("✗ Bot连接失败")
            
    except Exception as e:
        print(f"✗ 检查Bot信息错误: {e}")
        
    finally:
        if 'client' in locals() and client.is_connected():
            await client.disconnect()
            print("已断开连接")

def main():
    """主函数"""
    print("=" * 50)
    print("Bot信息检查工具")
    print("=" * 50)
    
    # 获取Bot Token
    bot_token = input("请输入您的Bot Token: ").strip()
    
    if not bot_token:
        print("❌ 请输入Bot Token")
        return
        
    # 检查Bot信息
    asyncio.run(check_bot_info(bot_token))

if __name__ == "__main__":
    main() 